﻿using System;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Windows;

namespace CodePlex.PropertyDesigner
{
    /// <summary>
    /// Interaction logic for PropertyDesignerControl.xaml
    /// </summary>
    public partial class PropertyDesignerControl
    {
        private ClassDesignerData _classDesignerData;
        private PropertyDesignerControlModel _viewModel;

        public PropertyDesignerControl()
        {
            InitializeComponent();
        }

        [SuppressMessage("Microsoft.Globalization", "CA1300:SpecifyMessageBoxOptions")]
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            MessageBox.Show(String.Format(CultureInfo.CurrentUICulture, "We are inside {0}.button1_Click()", this), "Property Designer");
        }

        public ClassDesignerData ClassDesignerData
        {
            get { return _classDesignerData; }
            set
            {
                if (_classDesignerData != value)
                {
                    _classDesignerData = value;
                    _viewModel = (_classDesignerData == null
                                      ? null
                                      : new PropertyDesignerControlModel(_classDesignerData));
                    DataContextRoot.DataContext = _viewModel;
                }
            }
        }
    }
}